package junit.source.pattern.wrapper;

import java.lang.reflect.Method;

public class FrameworkMethod {

    private Method method;

    public FrameworkMethod(Method method) {
        this.method = method;
    }

    /**
     * 包装的目的
     *
    {@link InvocationTargetException}s thrown are unwrapped, and their causes rethrown.
     *
     */
    public Object invokeExplosively(Object target, Object... param) throws Throwable {

        return new ReflectiveCallable() {

            @Override
            protected Object runReflectiveCall() throws Throwable {
                return method.invoke(target, param);
            }
        }.run();
    }
}
